# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgbase=python-pytesseract
pkgname=('python2-pytesseract' 'python-pytesseract')
_pkgname=pytesseract
pkgver=0.3.13
pkgrel=2
pkgdesc="Python-tesseract is a python wrapper for Google's Tesseract-OCR."
arch=('any')
url='https://pypi.org/project/pytesseract/#files'
license=('GPL3')
makedepends=('python2-setuptools' 'python-setuptools')
source=("https://files.pythonhosted.org/packages/source/${_pkgname::1}/$_pkgname/$_pkgname-$pkgver.tar.gz")
sha512sums=('ab959697485bd9bb98609e2343dfb7245b43067603d4dc62c30c03231a63f863a35bdfac881c6357823c685980cdf966ab590c61a0f56a43c71bc4e131977df2')

prepare() {
  cp -a "$_pkgname-$pkgver"{,-2}
}

build() {
  cd "$_pkgname-$pkgver-2"

  python2 setup.py build

  cd "$srcdir/$_pkgname-$pkgver"

  python setup.py build
}

package_python2-pytesseract() {
  depends=('python2' 'python2-pillow6')

  cd "$_pkgname-$pkgver-2"

  python2 setup.py install --root="$pkgdir" --prefix=/usr --skip-build

  mv "$pkgdir/usr/bin/$_pkgname" "$pkgdir/usr/bin/${_pkgname}2"
}

package_python-pytesseract() {
  depends=('python' 'python-pillow')

  cd "$_pkgname-$pkgver"

  python setup.py install --root="$pkgdir" --prefix=/usr -O1 --skip-build
}

